using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using MicroMsg.UI.Page;
using MicroMsg.UI.UserContrl;
using System;
using System.Windows.Media.Imaging;
namespace MicroMsg.Plugin.PluginDemo
{
	public class PluginDemo : PluginBase
	{
		private enum ExtServiceType
		{
			ExtService1 = 128
		}
		public class ExtServiceInputArgs
		{
			public int value1;
			public string value2;
		}
		public class ExtServiceResult
		{
			public int value3;
			public string value4;
		}
		private enum DestServiceType
		{
			DstService1 = 128
		}
		public class DestServiceInputArgs
		{
			public int value1;
			public string value2;
		}
		public class DestServiceResult
		{
			public int value3;
			public string value4;
		}
		private const string TAG = "PluginDemo";
		public const string PluginKey = "plugin demo";
		public const long PluginID = 32768L;
		public const string PluginName = "PluginDemo";
		public const int PluginVersion = 256;
		private static PluginBase mInstance;
		public override string mTitle
		{
			get
			{
				return "DemoPlugin";
			}
		}
		public override BitmapSource mIcon
		{
			get
			{
				if (MMTheme.IsCoolBlackTheme())
				{
					return ImageCacheMgr.loadFromRes("Source/Plugin/ViewQQInfo/Resource/Img/plugin_setting_cool.png");
				}
				return ImageCacheMgr.loadFromRes("Source/Plugin/ViewQQInfo/Resource/Img/plugin_setting_normal.png");
			}
		}
		public override BitmapSource mIconHD
		{
			get
			{
				return null;
			}
		}
		public override BitmapSource mIconInList
		{
			get
			{
				if (MMTheme.IsCoolBlackTheme())
				{
					return ImageCacheMgr.loadFromRes("Source/Plugin/ViewQQInfo/Resource/Img/plugin_setting_cool.png");
				}
				return ImageCacheMgr.loadFromRes("Source/Plugin/ViewQQInfo/Resource/Img/plugin_setting_normal.png");
			}
		}
		public override string mDescription
		{
			get
			{
				return "just a demo plugin";
			}
		}
		public override string mAuthor
		{
			get
			{
				return "tencent";
			}
		}
		public PluginDemo()
		{
			this.mKey = "plugin demo";
			this.mID = 32768L;
			this.mName = "PluginDemo";
			this.mVersion = 256;
			this.mIndexInTab = MainTabIndex.ContactTab;
			this.mIndexInGroup = 2;
			this.mIndexInPosition = 0;
			this.mDefaultInstalled = true;
			PluginDemo.mInstance = this;
		}
		public override PluginSettingBaseCtrl GetPluginSettingCtrl()
		{
			return null;
		}
		public static PluginDemo getInstance()
		{
			return PluginDemo.mInstance as PluginDemo;
		}
		public override void onRegisterResult(RetConst retConst_0, int code)
		{
			Log.smethod_4("PluginDemo", string.Concat(new object[]
			{
				"on register result , ret = ",
				retConst_0,
				", code = ",
				code
			}));
		}
		public override bool onInitialize()
		{
			Log.smethod_4("PluginDemo", "initialize. ");
			return true;
		}
		public override bool onUnInitialize()
		{
			PluginDemo.mInstance = null;
			return true;
		}
		public override bool onInstalled(InstallMode mode)
		{
			Log.smethod_4("PluginDemo", "on inistalled. ");
			return true;
		}
		public override bool onUninstalled(InstallMode mode)
		{
			Log.smethod_4("PluginDemo", "on uninstalled. ");
			return true;
		}
		public override void onAppActivated()
		{
		}
		public override void onAppDeactivated()
		{
		}
		public override object execute(int entryType, object args)
		{
			Log.smethod_4("PluginDemo", "plugin execute,   entrytype =" + entryType);
			return this.test_execute(entryType, args);
		}
		private void test_accessSystemApi()
		{
			string arg_0A_0 = AccountMgr.getCurAccount().strUsrName;
		}
		private object test_execute(int entryType, object args)
		{
			if (entryType == 1)
			{
				return null;
			}
			if (entryType == 2)
			{
				return null;
			}
			if (entryType == 3)
			{
				return null;
			}
			if (entryType == 4)
			{
				return null;
			}
			if (entryType == 128)
			{
				PluginDemo.ExtServiceInputArgs extServiceInputArgs = ExtentCenter.AsObject<PluginDemo.ExtServiceInputArgs>(args);
				return new PluginDemo.ExtServiceResult
				{
					value3 = extServiceInputArgs.value1 + 1
				};
			}
			return null;
		}
		private static void test_startupFromSetting()
		{
			PluginBase plugin = ExtentCenter.findPluginByName("PluginDemo");
			ExtentCenter.executePlugin(plugin, 4, null);
		}
		private static PluginDemo.DestServiceResult test_callDestService(PluginDemo.DestServiceInputArgs inArgs)
		{
			PluginBase plugin = ExtentCenter.findPluginByName("PluginDemo");
			object srcObject = ExtentCenter.executePlugin(plugin, 128, inArgs);
			return ExtentCenter.AsObject<PluginDemo.DestServiceResult>(srcObject);
		}
		public static void testPluginDemo()
		{
			PluginDemo.test_startupFromSetting();
			PluginDemo.DestServiceResult destServiceResult = PluginDemo.test_callDestService(new PluginDemo.DestServiceInputArgs
			{
				value1 = 2
			});
			destServiceResult.value3++;
		}
	}
}
